
BINNAME=Ex2

OBJECTS=main.o Picture.o HumanPicture.o GrabcutFilter.o BlenderFilter.o FilterWindow.o


FLAGS=-Wall

# Open CV Dependencies
OPENCV=`pkg-config --cflags opencv` `pkg-config --libs opencv`

SRCDIR=src
BINDIR=bin
HDRDIR=include
IMGDIR=images

FOREGROUND=$(BINDIR)/$(IMGDIR)/forrestgump.jpg
BACKGROUND=$(BINDIR)/$(IMGDIR)/bgu.jpg

SANITYNAME=memorySanity

default: $(OBJECTS)
	g++ $(FLAGS) $(OBJECTS) $(OPENCV) -I$(HDRDIR) -o $(BINDIR)/$(BINNAME)

$(OBJECTS):
	g++ -c $(FLAGS) $(SRCDIR)/$*.cpp $(OPENCV) -I$(HDRDIR) -o $@

test-mem: default
	valgrind $(BINDIR)/$(BINNAME) $(FOREGROUND) $(BACKGROUND)

# opencv leak test
leak-sanity: 
	g++ $(FLAGS) $(OPENCV) -o $(BINDIR)/$(SANITYNAME) $(SRCDIR)/$(SANITYNAME).cpp 

leak-sanity-test: leak-sanity
	valgrind $(BINDIR)/$(SANITYNAME)


tar: clean
	rm -f *.jpg
	rm -fr /tmp/$(BINNAME)
	svn export . /tmp/$(BINNAME)
	tar -C /tmp/$(BINNAME) -czf $(BINNAME).tar.gz *
clean:
	rm -f *.o $(BINDIR)/$(BINNAME) $(BINNAME).tar.gz
